#!/usr/bin/env bash
set -e

[[ ! $GIT_REFLOG_ACTION =~ pull ]] && exit 0

LOG=$(git log -U0 --oneline -p HEAD@{1}..HEAD GLOCKFILE)
[ -z "$LOG" ] && echo "glock: no changes to apply" && exit 0
echo "glock: applying updates..."
glock apply github.com/cockroachdb/cockroach <<< "$LOG"
